from core.basehandler import BaseHandler
from core.room import Room
from core.support import set_cutscene, get_game
from core.action import Action

class Elevator(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        self.elevator_lock = True
        # build list of actions
        self.add_action(Back)
        self.add_action(Up)
    
    def get_description(self):
        if self.elevator_lock:
            desc = "You need keycard access after hours.  Please swipe your keycard to access the elevator."
        else:
            desc = "You have been granted access to the elevator."
        return desc

    def get_image(self):
        if self.elevator_lock:
            return 'closed_elevator.jpg'
        else:
            return 'opened_elevator.jpg'
        
   
    # report whether this room is illuminated
    # which can happen if the room or player has a lit lamp
class ElevatorHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Elevator

# define actions for this room

class Up(Action):
    def __init__(self):
        Action.__init__(self, "Up")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Head up to the 9th floor where there is rooftop access"
    
    # set cutscene for when arrive in entrance_hall
    def do_action(self,game,room,request):
        set_cutscene("You get out from the elevator.")
        return
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'rooftop'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
    def is_enabled(self):
        if self.room.elevator_lock:
            return False
        else:
            return True


class Back(Action):
    def __init__(self):
        Action.__init__(self, "Back")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Return to Professor Wyners office"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'lubin_office'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"